using UnityEngine;

namespace Flaschengeist.Views 
{
	public class ProgressView : BaseView
	{		
		private Texture2D progressBarFilled;	
		private Texture2D progressBarEmpty;		
		private Vector2 size = new Vector2(140, 20);
		private Vector2 pos = new Vector2(0,0);
		private float progress;
		private float maxProgress;
		
		public void Init(int maxProgress, Vector2 pos)
		{
			this.pos = pos;
			this.maxProgress = maxProgress;
			this.progressBarFilled = (Texture2D)Resources.Load("Textures/gui_progressbar");
			this.progressBarEmpty= (Texture2D)Resources.Load("Textures/gui_progressbar_border");
		}
				
		public void OnGUI()
		{					
			if (IsActive)
			{	
				GUI.DrawTexture(new Rect(pos.x, pos.y, (size.x / maxProgress) * progress, size.y), progressBarFilled);	
				GUI.DrawTexture(new Rect(pos.x, pos.y, size.x, size.y), progressBarEmpty);
			}
		}
		
		public void SetProgress(float progress)
		{
			this.progress = progress;	
		}
	}
}

